﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinFormsAppTest.Class;
using WinFormsAppTest.Control;

namespace WinFormsAppTest
{
    public partial class Form2 : Form
    {
        //
        public String username = "null";//设置默认登录用户(手动添加)
        public int id = 0;//设置默认登录用户(手动添加)
        //
        public Form2()
        {
            InitializeComponent();
        }

        // -------有参 窗口（手动添加）--------
        public Form2(String name, int uid)
        {
            username = name;
            id = uid;
            InitializeComponent();
            Loginlabel.Text = username;
        }
        //-----------------------------------

        private void Form2Closing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                // 关闭进程
                Process.GetCurrentProcess().Kill();
            }
        }

        private void Exit_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form1 f = new Form1();
            f.ShowDialog();
            this.Dispose();
        }

        private void Test_Click(object sender, EventArgs e)
        {
            if (id != 0)
            {
                MessageBox.Show("测试成功！" + "用户id为：" + id);
            }
            else
            {
                MessageBox.Show("测试失败！");
            }
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            timer1.Interval = 1000;
            timer1.Start();
        }

        private void UsertreeView_Click(object sender, EventArgs e)
        {
            //if (UsertreeView.SelectedNode.Text == "首页")
            //{
            //    MessageBox.Show("首页");
            //}
        }

        private void UserTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (UsertreeView.SelectedNode.Text == "首页")
            {
                //MessageBox.Show("首页");
                datapanel.Controls.Clear();
                datapanel.Controls.Add(pictureBox1);
            }
            else if (UsertreeView.SelectedNode.Text == "个人档案查询")
            {
                //MessageBox.Show("个人档案");
                datapanel.Controls.Clear();
                UserFilesSearchControl f = new UserFilesSearchControl(id);
                datapanel.Controls.Add(f);

            }
            //else if (UsertreeView.SelectedNode.Text == "个人档案提交")
            //{
            //    MessageBox.Show("档案提交");


            //}
            else if (UsertreeView.SelectedNode.Text == "个人人事变动查询")
            {
                //MessageBox.Show("个人档案");
                datapanel.Controls.Clear();
                UserChangeSearchControl f = new UserChangeSearchControl(id);
                datapanel.Controls.Add(f);
            }
            else if (UsertreeView.SelectedNode.Text == "个人人事变动申请")
            {
                //MessageBox.Show("人事变动申请");
                ChangeAddForm changeUpdate = new ChangeAddForm("user", id);
                this.Hide();
                changeUpdate.ShowDialog();
                this.Dispose();

            }
            else if (UsertreeView.SelectedNode.Text == "个人考核情况查询")
            {
                //MessageBox.Show("个人档案");
                datapanel.Controls.Clear();
                UserExamSearchControl f = new UserExamSearchControl(id);
                datapanel.Controls.Add(f);
            }
            //else if (UsertreeView.SelectedNode.Text == "个人考核情况反馈")
            //{
            //    MessageBox.Show("考核情况反馈");
            //}
            else if (UsertreeView.SelectedNode.Text == "签到查询")
            {
                //MessageBox.Show("个人档案");
                datapanel.Controls.Clear();
                UserSignsSearchControl f = new UserSignsSearchControl(id);
                datapanel.Controls.Add(f);
            }
            else if (UsertreeView.SelectedNode.Text == "加班情况查询")
            {
                //MessageBox.Show("个人档案");
                datapanel.Controls.Clear();
                UserOvertimeSearchControl f = new UserOvertimeSearchControl(id);
                datapanel.Controls.Add(f);
            }
            else if (UsertreeView.SelectedNode.Text == "加班申请")
            {
                MessageBox.Show("加班申请");
                OvertimeAddForm changeUpdate = new OvertimeAddForm("user", id);
                this.Hide();
                changeUpdate.ShowDialog();
                this.Dispose();
            }
            else if (UsertreeView.SelectedNode.Text == "出差情况查询")
            {
                //MessageBox.Show("个人档案");
                datapanel.Controls.Clear();
                UserOuttimeSearchControl f = new UserOuttimeSearchControl(id);
                datapanel.Controls.Add(f);
            }
            else if (UsertreeView.SelectedNode.Text == "出差申请")
            {
                MessageBox.Show("出差申请");
                OuttimeAddForm changeUpdate = new OuttimeAddForm("user", id);
                this.Hide();
                changeUpdate.ShowDialog();
                this.Dispose();
            }
        }

        private void textBox1_enter(object sender, EventArgs e)
        {

        }

        private void textBox1_leave(object sender, EventArgs e)
        {


        }

        private void timer1_Tick(object sender, EventArgs e)
        {

        }
    }
}
